import Main from '@/views/Main.vue'

// 不作为Main组件的子页面展示的页面单独写，如下
export const loginRouter = {
  path: '/login',
  name: 'login',
  meta: {
    title: '云丁智能设备管理系统 - 登录'
  },
  component: () =>
        import('@/views/login.vue')
}
export const guideRouter = {
  path: '/guide/:step',
  name: 'guide',
  component: () =>
        import('@/views/index/guide.vue')
}

export const page404 = {
  path: '/*',
  name: 'error-404',
  meta: {
    title: '404-页面不存在'
  },
  component: () =>
        import('@/views/error-page/404.vue')
}

export const page403 = {
  path: '/403',
  meta: {
    title: '403-权限不足'
  },
  name: 'error-403',
  component: () =>
        import('@//views/error-page/403.vue')
}

export const page500 = {
  path: '/500',
  meta: {
    title: '500-服务端错误'
  },
  name: 'error-500',
  component: () =>
        import('@/views/error-page/500.vue')
}

const helpSpace = {
  path: 'help-space',
  title: '帮助中心',
  name: 'helpspace-wrap',
  redirect: { name: 'helpspace-handbook' },
  component: () =>
        import('@/views/help-space/help-space.vue'),
  children: [{
    path: 'handbook',
    name: 'helpspace-handbook',
    component: () =>
            import('@/views/help-space/help-space-handbook.vue')
  },
  {
    path: 'questions',
    name: 'helpspace-questions',
    component: () =>
            import('@/views/help-space/help-space-questions.vue')
  },
  {
    path: 'video',
    name: 'helpspace-video',
    component: () =>
            import('@/views/help-space/help-space-video.vue')
  }
  ]
}

// 作为Main组件的子页面展示但是不在左侧菜单显示的路由写在otherRouter里
export const otherRouter = {
  path: '/',
  name: 'otherRouter',
  redirect: '/home',
  component: Main,
  children: [helpSpace, {
    path: 'message',
    title: '消息中心',
    name: 'message_index',
    component: () =>
        import('@/views/message/message.vue')
  }]
}

// 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
export const appRouter = [{
  path: '/',
  icon: 'home',
  name: 'index',
  title: '首页',
  component: Main,
  children: [{
    path: 'home',
    title: '首页',
    name: 'home_index',
    permissionKey: 'every',
    component: () =>
            import('@/views/index/index.vue')
  }]
},
{
  path: '/tenancy-device',
  icon: 'devices',
  title: '设备',
  name: 'tenancy-device',
  component: Main,
  children: [{
    path: '/',
    title: '设备',
    name: 'tenancy_index',
    permissionKey: 'homes_view',
    component: () =>
            import('@/views/tenancy-device/homeList.vue'),
    children: [{
      path: ':homeId',
      title: '设备',
      name: 'tenancy_home-detail',
      permissionKey: 'device_base',
      component: () =>
                import('@/views/tenancy-device/homeDetail.vue'),
      props: true
    }]
  }]
},
{
  path: '/house',
  icon: 'houses',
  name: 'house-management',
  title: '房源',
  component: Main,
  children: [{
    path: 'home-list',
    icon: 'ios-home-outline',
    name: 'home-list',
    permissionKey: 'homes_view',
    title: '房源',
    component: () =>
        import('@/views/house-management/houseList.vue')
  }]
},
{
  path: '/renter',
  icon: 'tenant',
  title: '租客',
  name: 'renter',
  component: Main,
  children: [{
    path: 'index',
    title: '租客',
    name: 'renter_index',
    permissionKey: 'lease_base',
    component: () => import('@/views/renter/renterList.vue')
  }]
},

{
  path: '/ticket',
  icon: 'services',
  title: '服务',
  name: 'ticket',
  component: Main,
  children: [{
    path: '/',
    title: '服务',
    name: 'ticket-index',
    permissionKey: 'ticket_base',
    component: () =>
        import('@/views/ticket/ticket.vue'),
    children: [{
      path: 'list/:type',
      name: 'ticket-list',
      // component: () => import ('@/views/ticket/list-components/ticket-list.vue'),
      meta: { activeName: 'ticket-index' }
    },
    {
      path: 'detail/:ticketId',
      name: 'ticket-detail',
      component: () =>
            import('@/views/ticket/detail-components/ticket-detail.vue'),
      meta: { activeName: 'ticket-index' }
    },
    {
      path: 'create',
      name: 'ticket-create',
      // component: () => import ('@/views/ticket/create-components/ticket-create.vue'),
      meta: { activeName: 'ticket-index' }
    },
    {
      path: 'edit/:ticketId',
      name: 'ticket-edit',
      component: () =>
            import('@/views/ticket/create-components/ticket-create.vue'),
      meta: { activeName: 'ticket-index' }
    }
    ]
  } ]
},

{
  path: '/stores',
  icon: 'stores',
  title: '门店',
  name: 'stores',
  component: Main,
  children: [{
    path: 'index',
    title: '门店',
    name: 'stores_index',
    permissionKey: 'org_base',
    component: () =>
        import('@/views/stores/storeList.vue')
  }]
},
{
  path: '/staff',
  icon: 'staff',
  title: '员工',
  name: 'staff',
  component: Main,
  children: [{
    path: '/',
    title: '员工',
    name: 'staff_index',
    permissionKey: 'org_base',
    component: () =>
            import('@/views/staff/staff.vue'),
    children: [{
      path: ':staffId',
      permissionKey: 'device_base',
      title: '员工授权',
      name: 'staff-visit',
      component: () =>
                import('@/views/staff/access-controll.vue'),
      props: true
    }]
  }]
},
{
  path: '/reporting',
  icon: 'reporting',
  title: '报表',
  name: 'reporting',
  component: Main,
  children: [{
    path: 'device_report',
    title: '设备报表',
    name: 'reportInfo',
    permissionKey: 'log_check',
    component: () =>
            import('@/views/reporting/device-report/report-index.vue')
  },
  {
    path: 'delivery_statistics',
    title: '交付统计',
    name: 'delivery_statistics',
    permissionKey: 'log_check',
    component: () =>
            import('@/views/reporting/delivery/delivery')
  },
  {
    path: 'abnormal_report',
    title: '异常报表',
    name: 'abnormal_report',
    permissionKey: 'log_check',
    component: () =>
            import('@/views/reporting/abnormalReport')
  },
  {
    path: 'electric_report',
    title: '电表抄表',
    name: 'electric_report',
    permissionKey: 'device_base',
    component: () =>
            import('@/views/reporting/electricReport')
  },
  {
    path: 'water_report',
    title: '水表抄表',
    name: 'water_report',
    permissionKey: 'device_base',
    component: () =>
            import('@/views/reporting/waterReport')
  },
  {
    path: 'electric_count',
    title: '用电统计',
    name: 'electric_count',
    permissionKey: 'device_base',
    component: () =>
            import('@/views/reporting/electriCount')
  },
  {
    path: 'electric-charge',
    title: '电表充值',
    name: 'electric_charge',
    permissionKey: 'device_base',
    component: () =>
            import('@/views/reporting/electric-charge')
  },
  {
    path: 'open_door_count',
    title: '开门统计',
    name: 'open_door_count',
    permissionKey: 'opt_client_face_access',
    component: () =>
            import('@/views/reporting/openDoorCount')
  }
  ]
},
{
  path: '/log',
  icon: 'log',
  title: '日志',
  name: 'log',
  component: Main,
  children: [{
    path: 'index',
    title: '日志',
    name: 'log_index',
    permissionKey: 'log_check',
    component: () =>
        import('@/views/log/log.vue')
  }]
},
{
  path: '/fund',
  icon: 'fund',
  title: '资金',
  name: 'fund',
  component: Main,
  children: [{
    path: 'account_information',
    title: '账户信息',
    name: 'account_information',
    permissionKey: 'finance_base',
    component: () =>
            import('@/views/fund/accountInformation')
  },
  {
    path: 'recharge_record',
    title: '费用中心',
    name: 'recharge_record',
    permissionKey: 'finance_base',
    component: () =>
            import('@/views/fund/rechargeRecord')
  }
    // {
    //     path: 'contract_information',
    //     title: '合同信息',
    //     name: 'contract_information',
    //     permissionKey: 33,
    //     component: () => import('@/views/fund/contractInformation')
    // },
    // {
    //     path: 'bill_information',
    //     title: '账单信息',
    //     name: 'bill_information',
    //     permissionKey: 33,
    //     component: () => import('@/views/fund/billInformation')
    // },
    // {
    //     path: 'invoice_record',
    //     title: '开票记录',
    //     name: 'invoice_record',
    //     permissionKey: 33,
    //     component: () => import('@/views/fund/invoiceRecord')
    // }
    // {
    //     path: 'withdrawals_record',
    //     title: '提现记录',
    //     name: 'withdrawals_record',
    //     permissionKey:'index',
    //     component: () => import('@/views/fund/withdrawalsRecord')
    // },
  ]
},
{
  path: '/config',
  icon: 'config',
  title: '配置',
  name: 'config',
  component: Main,
  children: [{
    path: 'elemeter',
    title: '用电配置',
    name: 'config_index',
    permissionKey: 'homes_device_config',
    component: () =>
            import('@/views/config/config.vue')
  },
  {
    path: 'lock',
    title: '安全配置',
    name: 'config_lock',
    permissionKey: 'homes_device_config',
    component: () =>
            import('@/views/config/lock-config/container.vue')
  },
    // {
    //     path: 'entrance_guard',
    //     title: '门禁配置',
    //     name: 'config_entrance_guard',
    //     permissionKey: 'opt_client_face_access',
    //     component: () =>
    //         import ('@/views/config/entranceGuard.vue')
    // },
  {
    path: 'in_out_abnormal',
    title: '出入异常配置',
    name: 'config_abnormal',
    permissionKey: 'opt_client_face_access',
    component: () =>
            import('@/views/config/InOutabnormal.vue')
  }
  ]
}
]

// 所有上面定义的路由都要写在下面的routers里
export const routers = [
  loginRouter,
  guideRouter,
  otherRouter,
  // preview,
  ...appRouter,
  page500,
  page403,
  page404
]
